﻿Imports DevComponents.DotNetBar

Public Class ucCapnhatHangnhap

    Private Sub ButtonItemThoat_Click(sender As Object, e As EventArgs) Handles ButtonItemThoat.Click
        Dim uc As New ucCapnhatHangnhap
        Me.Controls.Add(uc)
        Dim parent = DirectCast(Application.OpenForms.Item(0), Main)
        parent.CloseModalPanel(uc, DevComponents.DotNetBar.Controls.eSlideSide.Right)
    End Sub

    Private Sub ButtonItemSave_Click(sender As Object, e As EventArgs) Handles ButtonItemSave.Click
        If ValidateData() Then
            MessageBoxEx.Show("true", "test", MessageBoxButtons.OK)
        Else
            MessageBoxEx.Show("false", "test", MessageBoxButtons.OK)
        End If
    End Sub

    Private Function ValidateData() As Boolean
        Dim validate As Boolean = True
        If ComboBoxExNhaCC.SelectedIndex = -1 Then
            validate = False
            ErrorProvider1.SetError(ComboBoxExNhaCC, "Vui lòng chọn nhà cung cấp")
            Highlighter1.SetHighlightColor(ComboBoxExNhaCC, Validator.eHighlightColor.Red)
        Else
            ErrorProvider1.SetError(ComboBoxExNhaCC, "")
            Highlighter1.SetHighlightColor(ComboBoxExNhaCC, Validator.eHighlightColor.None)

            If DataGridViewXHanghoa.RowCount = 0 Then
                validate = False
                ErrorProvider1.SetError(DataGridViewXHanghoa, "Vui lòng chọn hàng hoá")
                Highlighter1.SetHighlightColor(DataGridViewXHanghoa, Validator.eHighlightColor.Red)
            Else
                ErrorProvider1.SetError(DataGridViewXHanghoa, "")
                Highlighter1.SetHighlightColor(DataGridViewXHanghoa, Validator.eHighlightColor.None)

                If ComboBoxExDachi.SelectedIndex = -1 Then
                    validate = False
                    ErrorProvider1.SetError(ComboBoxExDachi, "Vui lòng chọn người chi")
                Else
                    ErrorProvider1.SetError(ComboBoxExDachi, "")
                End If
            End If

        End If

        Return validate
    End Function

    Private Sub ComboBoxExNhaCC_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxExNhaCC.SelectedIndexChanged
        If ComboBoxExNhaCC.SelectedIndex > -1 Then
            DataGridViewXHanghoa.ReadOnly = False
            DataGridViewXHanghoa.DataSource = Nothing
        End If
    End Sub

    Private Sub ButtonItemThemNhaCC_Click(sender As Object, e As EventArgs) Handles ButtonItemThemNhaCC.Click
        'Dim uc As New ucCapnhatcongty()
        'uc.Dock = DockStyle.Fill
        'Dim parent = DirectCast(Application.OpenForms.Item(0), Main)
        'parent.ShowModalPanel(uc, DevComponents.DotNetBar.Controls.eSlideSide.Left)
    End Sub

    Private Sub ButtonItemThemHangHoa_Click(sender As Object, e As EventArgs) Handles ButtonItemThemHangHoa.Click
        'Dim uc As New ucCapnhathanghoa
        'uc.Dock = DockStyle.Fill
        'Dim parent = DirectCast(Application.OpenForms.Item(0), Main)
        'parent.ShowModalPanel(uc, DevComponents.DotNetBar.Controls.eSlideSide.Left)
    End Sub
End Class
